package com.bzqn.baseframe;

import java.util.ArrayList;
import java.util.List;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

public class BZQNWelcomeActivity extends AbstructBaseActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		ViewPager welcomePager  = new ViewPager(this);
		welcomePager.setBackgroundColor(Color.BLUE);
		welcomePager.setAdapter(new MyViewPagerAdapter(initWelcomeViews()));
		setContentView(welcomePager);
	}
	protected List<View> initWelcomeViews() {
		ImageView i = new ImageView(this);
		i.setBackgroundColor(Color.RED);
		ImageView i1 = new ImageView(this);
		i1.setBackgroundColor(Color.BLACK);
		ImageView i2 = new ImageView(this);
		i2.setBackgroundColor(Color.YELLOW);
		ImageView i3 = new ImageView(this);
		i3.setBackgroundColor(Color.GRAY);
		List<View> views = new ArrayList<View>();
		views.add(i);
		views.add(i1);
		views.add(i2);
		views.add(i3);
		return views;
	}
	
	@Override
	void onHttpRet(String content) {

	}
	class MyViewPagerAdapter extends PagerAdapter{  
	    private List<View> views;  
	      
	    public MyViewPagerAdapter(List<View> views) {  
	        this.views = views;//构造方法，参数是我们的页卡，这样比较方便。  
	    }  

	    @Override  
	    public void destroyItem(ViewGroup container, int position, Object object)   {     
	        container.removeView(views.get(position));//删除页卡  
	    }  


	    @Override  
	    public Object instantiateItem(ViewGroup container, int position) {  //这个方法用来实例化页卡         
	         container.addView(views.get(position), 0);//添加页卡  
	         return views.get(position);  
	    }  

	    @Override  
	    public int getCount() {           
	        return  views.size();//返回页卡的数量  
	    }  
	      
	    @Override  
	    public boolean isViewFromObject(View arg0, Object arg1) {             
	        return arg0==arg1;//官方提示这样写  
	    }  
	}  

}
